<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%@ include file="/page/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<%@ include file="/adapter/adapter-bootstrap.jsp"%>
<script type="text/javascript">
	var basePageMake = "${ctx}/auth/appPushMessage";
	function rowClickAfter(rowIndex, pk_id) {
		var arrId = document.getElementsByName("check");
		arrId[rowIndex - 1].checked = true;
	}

	//新增
	function doAdd() {
		window.location.href = "${ctx}/appWxMenuConfig/jumpAddWxMenuConfig?appid=${appid}";
	}
	//修改
	function doEdit() {
		if (recordKey == null) {
			alert("请选择一条记录！");
		} else {
			window.location.href = "${ctx}/appWxMenuConfig/jumpUpdateWxMenuConfig?appid=${appid}&recordKey="
					+ recordKey;
		}
	}
	//删除
	function doDelete() {
		if (recordKey == null) {
			alert("请选择一条记录！");
		} else {
			if (confirm("确认删除吗？")) {
				$.ajax({
							url : "${ctx}/appWxMenuConfig/deleteWxMenuConfig?appid=${appid}&recordKey="
									+ recordKey,
							type : "POST",
							dataType : "json",
							async : false,
							success : function(data) {
								if (data.flag > 0) {
									alert("删除成功！");
									window.location.reload();
								}
							},
							error : function() {
								alert("error");
							}
						});
			}
		}
	}
	//查看
	function doView() {
		if (recordKey == null) {
			alert("请选择一条记录！");
		} else {
			window.location.href = "${ctx}/appWxMenuConfig/queryWxMenuConfigDetail?appid=${appid}&recordKey="
					+ recordKey;
		}
	}
	
</script>
</head>
<body>
	<div class="panel panel-default">
		<div class="panel-heading">
			<h3 class="panel-title">微信菜单配置</h3>
		</div>
		<div class="panel-body">
			<form class="form-horizontal" role="form" method="post"
				action="${ctx}/auth/wxMenuConfig?appid=${appid}">
				<div class="form-group">
					<label class="col-xs-2 control-label" for="wx_menu_id">菜单id：</label>
					<div class="col-xs-3">
						<input class="input-sm form-control" id="wx_menu_id"
							name="wx_menu_id" type="text" value="" />
					</div>
					<label class="col-xs-2 control-label" for="wx_menu_name">菜单名：</label>
					<div class="col-xs-3">
						<input class="input-sm form-control" id="wx_menu_name"
							name="wx_menu_name" type="text" value="" />
					</div>
					<div class="col-xs-2">
						<button type="submit" class="btn btn-default btn-sm">查询</button>
					</div>
				</div>
			</form>
		</div>
	</div>
	<div class="op-btn">
		<input type="button" class="btn btn-default" name="update" value="修改"onclick="doEdit()" /> 
		<input type="button" class="btn btn-default"name="view" value="查看" onclick="doView()" />
		 <input type="button"class="btn btn-default" name="add" value="新增" onclick="doAdd()" />
		  <input type="button" class="btn btn-default" name="delete" value="删除" onclick="doDelete()" />
	</div>
	<macms:table dataListName="wxList">
		<macms:html id="ch" label="选择" innerHtml="<input type=\"radio\" name=\"check\" value=\"15\">"></macms:html>
		<macms:text id="wx_menu_id" label="菜单ID" align="center"></macms:text>
		<macms:text id="wx_menu_name" label="菜单名" align="center"></macms:text>
		<macms:text id="app_id" label="APPID"  align="center"></macms:text>
		<macms:text id="wx_menu_type" label="菜单类型" align="center"></macms:text>
		<macms:text id="parent_menu_id" label="父菜单ID" align="center"></macms:text>
		<macms:text id="wx_menu_rank" label="序号" align="center"></macms:text>
		<macms:text id="wx_resp_actionid" label="响应动作编号" align="center"></macms:text>
		<macms:text id="wx_event_key" label="微信事件推送值" align="center"></macms:text>
		<macms:text id="wx_menu_url" label="菜单链接" align="center"></macms:text>
	</macms:table>
	<script type="text/javascript">
		var preRow = null;
		var recordKey;
		$('tbody tr').bind('click', function() {

			var rowIndex = $(this).prevAll().length + 1;
			if (rowIndex < 1)
				return;

			if (preRow != null) {
				preRow.removeClass("active");
			}
			$(this).addClass("active");
			preRow = $(this);
			recordKey = $(this).find("td").eq(1).text();
			// 行单击后事件(传入行号，页面标识)
			rowClickAfter(rowIndex, $(this).find("td").eq(1).text());
		});
	</script>
</body>
</html>

